﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KPIS.GERP.GFMS.MODEL;
using KPIS.GERP.GFMS.IBLL;
using KPIS.GERP.GFMS.IDAL;
using KPIS.GERP.GFMS.DALFactory;

// test only
using KPIS.GERP.GFMS.DAL;

namespace KPIS.GERP.GFMS.BLL
{
    public class B_BGM_Project : IBLL_BGM_Project
    {
        Common common = new Common();
        private static readonly IDAL_BGM_Project dal = DataAccess.Create_BGM_Project();

        public B_BGM_Project()
        {

        }

        public IList<M_BGM_Project> GetFull(string bgm_year
            , string job_site_seq, string bgm_option_seq)
        {
            //Nullable<int> nbgm_source_seq = common.ConvertNullInt(bgm_source_seq);
            Nullable<int> nbgm_year = common.ConvertNullInt(bgm_year);
            Nullable<int> njob_site_seq = common.ConvertNullInt(job_site_seq);
            Nullable<int> nbgm_option_seq = common.ConvertNullInt(bgm_option_seq);
            return dal.GetFull(nbgm_year, njob_site_seq, nbgm_option_seq);
        }

        public IList<M_BGM_Project> GetBudget(string bgm_proj_seq, string bgm_source_seq
            , string bgm_proj_oper_seq)
        {
            Nullable<int> nbgm_proj_seq = common.ConvertNullInt(bgm_proj_seq);
            Nullable<int> nbgm_source_seq = common.ConvertNullInt(bgm_source_seq);
            Nullable<int> nbgm_proj_oper_seq = common.ConvertNullInt(bgm_proj_oper_seq);
            return dal.GetBudget(nbgm_proj_seq, nbgm_source_seq, nbgm_proj_oper_seq);
        }

        public IList<M_BGM_Project> GetList(string bgm_year
            , string job_site_seq, string bgm_option_seq)
        {
            //Nullable<int> nbgm_source_seq = common.ConvertNullInt(bgm_source_seq);
            Nullable<int> nbgm_year = common.ConvertNullInt(bgm_year);
            Nullable<int> njob_site_seq = common.ConvertNullInt(job_site_seq);
            Nullable<int> nbgm_option_seq = common.ConvertNullInt(bgm_option_seq);
            return dal.GetList(nbgm_year, njob_site_seq, nbgm_option_seq);
        }

        public M_BGM_Project GetInfo(string seq)
        {
            int nSeq;

            if (seq == null)
                return null;

            if (common.IsNumeric(seq))
            {
                nSeq = int.Parse(seq);
                return dal.GetInfo(nSeq);
            }
            else
            {
                return null;
            }
        }
    }
}
